import axios from 'axios'
export function get(url,params={}){
    return new Promise((resolve,reject) => {
      axios({
        method: 'GET',
        url: url,
        headers: {
         'Content-Encoding': 'gzip',
         'Content-Type': 'application/x-www-form-urlencoded; charset=utf-8',
       },
       data: params
      }).then(response => {
        resolve(response.data);
      })
      .catch(err => {
        reject(err)
      })
    })
  }
  export function post(url,data = {}){
    return new Promise((resolve,reject) => {
      axios({
        method: 'POST',
        url: url,
        headers: {
         'Content-Type': 'application/json'
       },
       data:data
      }).then(response => {
       resolve(response.data);
     },err => {
       reject(err)
     })
    })
  }

  export function del(url,data = {}){
    return new Promise((resolve,reject) => {
      axios({
        method: 'DELETE',
        url: url,
        headers: {
         'Content-Type': 'application/json'
       },
       data:data
      }).then(response => {
       resolve(response.data);
     },err => {
       reject(err)
     })
    })
  }  


  export function put(url,data = {}){
    return new Promise((resolve,reject) => {
      axios({
        method: 'PUT',
        url: url,
        headers: {
         'Content-Type': 'application/json'
       },
       data:data
      }).then(response => {
       resolve(response.data);
     },err => {
       reject(err)
     })
    })
  }  